package com.gitee.magic.jdbc.spring.schema;

import java.util.Map;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

import com.gitee.magic.jdbc.persistence.source.jdbc.mapper.MapperManager;
import com.gitee.magic.jdbc.spring.annotations.EnabledOrmMapperScan;

/**
 * @author start
 */
public class OrmMapperRegister implements ImportBeanDefinitionRegistrar {

	@Override
	public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
		Map<String,Object> params=importingClassMetadata.getAnnotationAttributes(EnabledOrmMapperScan.class.getName());
		for(String key:params.keySet()) {
			if("mapperPackage".equals(key)) {
				MapperManager manager=new MapperManager();
				manager.start((String[])params.get(key));
			}
		}
	}

}
